package com.situ.day25.factory;

import org.junit.Test;

import java.io.IOException;

public class FactoryDemo {

    public static void main(String[] args) {
        //既要知道接口，又要知道实现类
        Cal cal = new Add();
        cal.setNumA(3);
        cal.setNumB(5);
        double result1 = cal.getResult();
        System.out.println(result1);

        cal = new Sub();
        cal.setNumA(3);
        cal.setNumB(5);
        double result2 = cal.getResult();
        System.out.println(result2);


    }

    @Test
    public void test1() throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException {
        //Cal cal = CalFactory.createCal("+");
        Cal cal = CalFactory.createCal();
        cal.setNumA(5);
        cal.setNumB(6);
        double result = cal.getResult();
        System.out.println(result);
    }
}
